package cn.tedu;
import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDome3 {
    @Test
    public void add() throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3307/jt_db?characterEncoding=utf-8&serverTimezone=Asia/Shanghai", "root", "root");
        Statement stat = connection.createStatement();
        int i = stat.executeUpdate("insert into acc value(null,'C',222.22)");
        ResultSet resultSet = stat.executeQuery("select*from acc");
        while (resultSet.next()){
            int id=resultSet.getInt("id");
            String name=resultSet.getString("name");
            double money=resultSet.getDouble("money");
            System.out.println(id+","+name+","+money);

        }
        resultSet.close();
        stat.close();
        connection.close();


    }
}
